﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBHelper;
using BusinessLayer.FindArtInfo.Entities;
using System.Data.SqlClient;
using System.Data;

namespace BusinessLayer.FindArtInfo
{
    public class ArtLinksCategoryBL
    {
        private readonly DbHelper _db;

        public ArtLinksCategoryBL()
        {
            _db = new DbHelper(new DbConfig().DbFindArtInfoConnectionString);         
        }

        public List<ArtLinksCategory> GetAll()
        {
            var oCommand = new SqlCommand("sp_ArtLinksCategory_Select_All") { CommandType = CommandType.StoredProcedure };            
            var list = _db.GetList<ArtLinksCategory>(oCommand);
            return list;
        }

        public ArtLinksCategory GetById(int id)
        {
            var oCommand = new SqlCommand("sp_ArtLinksCategory_Select_By_Id") { CommandType = CommandType.StoredProcedure };
            oCommand.Parameters.Add(new SqlParameter("@Id", id));
            var list = _db.GetList<ArtLinksCategory>(oCommand);
            return list.FirstOrDefault();
        }
    }
}
